<?php
/**
 * Created by PhpStorm.
 * User: huanglinjie
 * Date: 2019/6/26
 * Time: 9:41 AM
 */

namespace app\util;


class Aes
{
    private $key = 'hsdj!23j@42#3g!q';

    private $hex_iv = 'j1s5#fsdfad#Dkj5';

    public function encrypt($input)
    {
        $data = openssl_encrypt($input, 'AES-128-CBC', $this->key, OPENSSL_RAW_DATA, $this->hex_iv);
        $data = base64_encode($data);
        return $data;
    }

    public function decrypt($input)
    {
        $decrypted = openssl_decrypt(base64_decode($input), 'AES-128-CBC', $this->key, OPENSSL_RAW_DATA, $this->hex_iv);
        return $decrypted;
    }

}